//
//  QBHttpRequestHeader.m
//  Qianbao
//
//  Created by liyan1 on 13-12-24.
//  Copyright (c) 2013年 qianwang365. All rights reserved.
//

#import "QBHttpRequestHeader.h"
#import "OpenUDID.h"
static QBHttpRequestHeader *requestHeaderInstance;

@interface QBHttpRequestHeader ()

@end

@implementation QBHttpRequestHeader

- (void)dealloc
{
    RELEASE_SAFELY(_commonHeader);
    [super dealloc];
}

+ (id)shareInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        requestHeaderInstance = _ALLOC_OBJ_(QBHttpRequestHeader);
    });
    return requestHeaderInstance;
}

#pragma mark -- getter
- (NSMutableDictionary*)commonHeader
{
    if(!_commonHeader)
    {
        _commonHeader = _ALLOC_OBJ_(NSMutableDictionary);
//        SET_PARAM(APP_DEV,                  @"devType",                 _commonHeader);
        SET_PARAM(kAgient,                  @"User-Agent",              _commonHeader);
        SET_PARAM(@"client",                @"sourceType",              _commonHeader);
//        SET_PARAM(kUMChannel,               @"channel",                 _commonHeader);
        SET_PARAM(APP_VERSION,              @"version",                 _commonHeader);
        SET_PARAM([OpenUDID value],         @"devId",                   _commonHeader);
//        SET_PARAM([QBUtil deviceString],    @"iOSversion",              _commonHeader);
        SET_PARAM(@"application/json",      @"Response-Content-Type",   _commonHeader);
        SET_PARAM(app_token,         @"app_token",                   _commonHeader);
        SET_PARAM(APPID,         @"appid",                   _commonHeader);
    }
    
//    _GET_APP_DELEGATE_(appDelegate);
//    QBLoginUserInfo *user = appDelegate.userDataInfo.loginInfo;
//    if (user.userId)
//    {
//        SET_PARAM(user.userId,      @"userId",      _commonHeader);
//    }
//    
//    if (user.sessionId)
//    {
//        SET_PARAM(user.sessionId,   @"jSessionId",  _commonHeader);
//    }
//    
//    if (user.realNameAuthenticated)
//    {
//        SET_PARAM(@"1",             @"userType",    _commonHeader);
//    }
//    
//    NSString *deviceToken = getObjectFromUserDefault(DICT_KEY_PUSH_DEVICE_TOKEN);
//    if (deviceToken)
//    {
//        SET_PARAM(deviceToken,      @"deviceToken", _commonHeader);
//    }
    
    return _commonHeader;
}


@end

